
PLUG.Platform = PLUG_PLATFORM_SERVER

PLUG.ClassName = "sh_chatadjust"
PLUG.PrintName = "Chat Adjustment Module"
PLUG.Author = "thomasfn"

function PLUG:AddHooks()
	// plugs.Hook( PLUG_PLATFORM_SERVER, "PlayerSay" )
	timer.Simple( 7, plugs.Call, "OverrideGamemodeChat" )
end

local ToReplace = {
	lol = "haha",
	rofl = "rolling on the floor, laughing",
	afk = "away from keyboard",
	lmao = "laughing my ass off",
	wtf = "what the hell",
	n00b = "noob",
	nub = "noob",
	minge = "minge-bag",
	stfu = "shut the hell up",
	hax = "hacks",
	h4x = "hacks",
	h4x0r = "hacker",
	haxor = "hacker",
	hax0r = "hacker",
	h4xr = "hacker",
	haxr = "hacker",
	[" ur "] = " you're ",
	[" u "] = " you "
}

function PLUG:OverrideGamemodeChat()
	GAMEMODE.OldPlayerSay = GAMEMODE.OldPlayerSay or GAMEMODE.PlayerSay
	GAMEMODE.PlayerSay = self.GMPlayerSay
end

function PLUG:GMPlayerSay( ply, text, public )
	if (ignorethis) then return end
	for k, v in pairs( ToReplace ) do
		text = string.Replace( text, k, v )
	end
	text = string.upper( string.Left( text, 1 ) ) .. string.Right( text, string.len( text ) - 1 )
	if (GAMEMODE.OldPlayerSay) then
		return GAMEMODE:OldPlayerSay( ply, text, public ) or text
	else
		return text
	end
end